<template>
    <div class="dashboard-editor-container">
        <panel-group @handleSetLineChartData="handleSetLineChartData" />

        <el-row class="container-box">
            <div class="title">{{ line_title }}</div>
            <line-chart :chart-data="lineChartData" />
        </el-row>

        <el-row :gutter="10">
            <el-col :xs="24" :sm="24" :lg="8">
                <div class="chart-wrapper">
                    <div class="title">预约项目情况</div>
                    <raddar-chart />
                </div>
            </el-col>
            <el-col :xs="24" :sm="24" :lg="8">
                <div class="chart-wrapper">
                    <div class="title">最近一周排队情况</div>
                    <pie-chart />
                </div>
            </el-col>
            <el-col :xs="24" :sm="24" :lg="8">
                <div class="chart-wrapper">
                    <div class="title">最近一周预约情况</div>
                    <bar-chart />
                </div>
            </el-col>
        </el-row>
    </div>
</template>

<script>
import PanelGroup from "./dashboard/PanelGroup";
import LineChart from "./dashboard/LineChart";
import RaddarChart from "./dashboard/RaddarChart";
import PieChart from "./dashboard/PieChart";
import BarChart from "./dashboard/BarChart";

const lineChartData = {
    purchases: {
        title: "当前预约",
        expectedData: [80, 100, 121, 104, 105, 90, 100],
        actualData: [120, 90, 100, 138, 142, 130, 130],
    },
    shoppings: {
        title: "当前排队",
        expectedData: [130, 140, 141, 142, 145, 150, 160],
        actualData: [120, 82, 91, 154, 162, 140, 130],
    },
    messages: {
        title: "历史预约",
        expectedData: [200, 192, 120, 144, 160, 130, 140],
        actualData: [180, 160, 151, 106, 145, 150, 130],
    }
};

export default {
    name: "Index",
    components: {
        PanelGroup,
        LineChart,
        RaddarChart,
        PieChart,
        BarChart,
    },
    data() {
        return {
            line_title: "预约",
            lineChartData: lineChartData.purchases,
        };
    },
    methods: {
        handleSetLineChartData(type) {
            this.line_title = lineChartData[type].title;
            this.lineChartData = lineChartData[type];
        },
    },
};
</script>

<style lang="scss" scoped>
.dashboard-editor-container {
    padding: 10px;
    background-color: rgb(240, 242, 245);
    position: relative;
    height: 92vh;

    .container-box {
        background: #fff;
        padding: 16px 16px 0;
        margin-bottom: 10px;
        box-shadow: 4px 4px 40px rgba(0, 0, 0, 0.1);
        border-color: rgba(0, 0, 0, 0.1);
        border-radius: 8px;
    }

    .chart-wrapper {
        background: #fff;
        padding: 16px 16px 0;
        box-shadow: 4px 4px 40px rgba(0, 0, 0, 0.1);
        border-color: rgba(0, 0, 0, 0.1);
        border-radius: 8px;
    }
}

@media (max-width: 1024px) {
    .chart-wrapper {
        padding: 8px;
    }
}
</style>
